/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Projects
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _DATE_TIME_HPP_
#define _DATE_TIME_HPP_

#include <string>
#include <iostream>


///@class DateTime
///@brief Type containing information on date and time value
class DateTime
{
public:
    ///@brief Default constructor
    DateTime();
    ///@brief Constructor with arguments
    DateTime(unsigned int, unsigned int, unsigned int, unsigned int,
             unsigned int, unsigned int);
    ///@brief Copy constructor
    DateTime(const DateTime&);
    ///@brief Destructor
    ~DateTime();
    ///@brief Overload of = operator
    DateTime& operator=(const DateTime &);
    ///@brief Return the date and time as a string with given format
    std::string AsString(std::string);
    ///@brief Set the DateTime object from a string with given format
    void SetWithFormat(std::string, std::string);
    ///@brief Return number of days from an initial date
    unsigned int NumberOfDays();
    ///@brief Return true if current year is bissextile
    bool IsBissextile();
    ///@brief Return the number of days in the current month
    unsigned int NumberOfDaysInTheMonth();
    ///@brief Normalize the contained values
    void Normalize();

    //Getters
    ///@brief Return hour value
    unsigned int GetHour();
    ///@brief Return minute value
    unsigned int GetMinute();
    ///@brief return second value
    unsigned int GetSecond();
    ///@brief Return year value
    unsigned int GetYear();
    ///@brief Return month value
    unsigned int GetMonth();
    ///@brief Return day value
    unsigned int GetDay();
    ///@brief Return index of day in the week. Monday = 1
    unsigned int GetDayOfWeek();

    //Setters
    ///@brief Set year value
    void SetYear(unsigned int);
    ///@brief Set month value
    void SetMonth(unsigned int);
    ///@brief Set day value
    void SetDay(unsigned int);
    ///@brief Set hour value
    void SetHour(unsigned int);
    ///@brief Set minute value
    void SetMinute(unsigned int);
    ///@brief Set second value
    void SetSecond(unsigned int);

    ///@brief Overload of << operator
    friend std::ostream& operator<<(std::ostream &, const DateTime&);
    ///@brief Overload of == operator : comparison of 2 DateTime objects
    friend bool operator==(const DateTime&, const DateTime&);
    ///@brief Overload of != operator : comparison of 2 DateTime objects
    friend bool operator!=(const DateTime&, const DateTime&);
    ///@brief Overload of < operator : comparison of 2 DateTime objects
    friend bool operator<(const DateTime&, const DateTime&);
    ///@brief Overload of > operator : comparison of 2 DateTime objects
    friend bool operator>(const DateTime&, const DateTime&);
    ///@brief Overload of <= operator : comparison of 2 DateTime objects
    friend bool operator<=(const DateTime&, const DateTime&);
    ///@brief Overload of >= operator : comparison of 2 DateTime objects
    friend bool operator>=(const DateTime&, const DateTime&);

protected:

private:
    unsigned int year;
    unsigned int month;
    unsigned int day;
    unsigned int hour;
    unsigned int minute;
    unsigned int second;
};

#endif // _DATE_TIME_HPP_
